<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\search\VideoSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '视频管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="video-index">
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
//            ['class' => 'yii\grid\SerialColumn'],
            [
                'attribute'=>'id',
                'options' => ['width' => '80px'],
            ],
            [

                'attribute'=>'wx_uid',
                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    return $model->user->showAvatar().'<br/>'.$model->user->nickname;
                }
            ],
            [

                'label'=>'发布',
                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    return Html::button('发布',['onclick'=>'publish('.$model->id.')','class'=>'btn btn-primary']);
                }
            ],
            [

                'label'=>'已发布',
                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    $str = '';
                    if(!empty($model->authItems)){
                        foreach($model->authItems as $authItem){
                            $str.=$authItem->authApp->showLogo().$authItem->authAccount->showAvatar().'&nbsp;&nbsp;'.$authItem->authAccount->showname().'<br/>'.$authItem->title.'<br/>';
                        }
                    }

                    return $str;
                }
            ],
//            'store',
            'title',
//            'cover',
//            'path',
            [

                'attribute'=>'size',
                'filter'=>false,
//                'format'=>'raw',
                'value'=>function($model){
                    return $model->showSize();
                }
            ],
            //'width',
            //'height',
            [

                'attribute'=>'duration',
                'filter'=>false,
//                'format'=>'raw',
                'value'=>function($model){
                    return $model->showDuration();
                }
            ],
            //'extension',
            [

                'attribute'=>'ctime',
                'options' => ['width' => '160px'],
                'filter'=>false,
//                'format'=>'raw',
                'value'=>function($model){
                    return date('Y-m-d H:i:s',$model->ctime);
                }
            ],
//            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>


</div>
